home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#26 (Nov 87)
/
Daisy C Print Driver
/
daisy printer sources
/
prglobals.h
< prev
next >
Wrap
Text File
|
1987-09-29
|
4KB
|
186 lines
#define nil 0L
#include <PrintMgr.h>
#include <DeviceMgr.h>
#include <FileMgr.h>
#include <Environs.h>
#define DIRTY 0xFFFF
/* LightspeedC doesn't do this exactly right for a Printer control call. */
typedef struct
{
QElemPtr qLink;
int qType;
int ioTrap;
Ptr ioCmdAddr;
ProcPtr ioCompletion;
OsErr ioResult;
StringPtr ioNamePtr;
int ioVRefNum;
int ioRefNum;
int csCode;
long lParam1;
long lParam2;
long lParam3;
/* ^^^^ */
} PrParam;
#define WIDTH 164 /* la bombe if not a multiple of 4 */
#define NROWS 66 /* 11 inches * lines per inch. */
typedef struct bauds{
int rate;
char label[10];
}BAUDS;
typedef struct{
int dirty;
unsigned char text[WIDTH];
}line,*pline,**hline;
typedef struct{
int dummy[5];
} pconfig,*Pcfg,**Pfg;
/* Be a real Mac cowboy, access data by the handle. */
#define pport ((*settings)->dummy[0])
#define pbaud ((*settings)->dummy[1])
#define XonXoff ((*settings)->dummy[2])
/* Yeeeeee-Hah !! I don't even lock it! */
typedef struct { /* Structure description of STR# */
int numstrings; /* resource. */
unsigned char thestrings[];
}stringlist,**StrList;
#define RES1ID (-4080)
#define RES2ID (-8192)
#define ILLEGAL 0x4AFC
typedef unsigned char Str36[36];
#define HREZZ 72
#define HREZZ10 60 /* For 10 cpi. */
#define HREZZ12 72 /* For 12 cpi. */
#define HREZZ15 90 /* For 15 cpi. */
#define VREZZ 66 /* This gives us 6 lines of printed text per inch. */
#define lines_per_inch 6
#define CHARWIDTH 6
#define CHARHEIGHT 11
#define iPrPrivate 99
#define VERSION 3
#define _DEBUG 0
#if _DEBUG
#define DEBUG asm{\
Debugger\
}
#else
#define DEBUG
#endif
#define IDEV10 0xFD01
#define IDEV12 0xFD02
#define IDEV15 0xFD03
/* HIgh order byte of IDEV is -3 for printer driver, low order byte is
* device specific. I use it to determine character pitch for daisy wheel
* devices and dot matrix in draft mode.
*/
#define SETUP_CMD 'Setp'
#define PRINT_CMD 'Prnt'
#define CLOSE_CMD 'Clos'
#define OPEN_CMD 'Open'
typedef struct{ /* Font characterization table for use by the */
int vres; /* Font Manager. */
int hres;
SignedByte bold[3];
SignedByte italic[3];
SignedByte notused[3];
SignedByte outline[3];
SignedByte shadow[3];
SignedByte condensed[3];
SignedByte extended[3];
SignedByte underline[3];
}fontab;
/*
* Shared storage, defined and initialized by the driver code, accessed
* elsewhere.
*/
#ifdef DRIVER_MODULE
#else
typedef struct{
#endif
#ifdef DRIVER_MODULE
BAUDS mybauds[] = { /* Baud rate constant table. */
{ baud300, "\p300"}, /* Should use a string list. */
{ baud600, "\p600"}, /* But these are numbers, so I */
{ baud1200, "\p1200"}, /* Think it's OK. */
{ baud1800, "\p1800"}, /* This has to be the FIRST */
{ baud2400, "\p2400"}, /* driver global to be declared, */
{ baud3600, "\p3600"}, /* since it is also used by our */
{ baud4800, "\p4800"}, /* PACK -4096 resource, which */
{ baud7200, "\p7200"}, /* needs to find it at the head */
{ baud9600, "\p9600"}, /* of PREC -8192. */
{ baud19200, "\p19200"}
};
Pfg settings = nil;
static PrParam prpb = {
nil, /* qLink */
0, /* qType */
0, /* ioTrap */
nil, /* ioCmdAddr */
nil, /* ioCompletion */
0, /* ioResult */
nil, /* ioNamePtr */
0, /* ioVRefNum */
iPrDrvrRef, /* ioRefNum */
0, /* csCode */
0L,0L,0L /* lParam[1-3] */
};
Str36 prname = sPrDrvr;
#else
BAUDS mybauds[10];
Pfg settings;
PrParam prpb;
Str36 prname;
#endif
ParamBlockRec iopb; /* For writing to the serial driver. */
#ifdef DRIVER_MODULE
static int phone = FALSE;
static int printer = FALSE;
#else
int phone;
int printer;
#endif
int drivernum; /* RefNum of serial driver to use. */
Str255 prinitstr;
Str36 prlfstr;
Str36 prtopstr;
Str36 preopstr;
Str36 preofstr;
#ifdef DRIVER_MODULE
static fontab myfonts = {
VREZZ,
HREZZ12,
{ 0, 2, 2},
{ 1, 8, 2},
{ 0, 0, 0},
{ 5, 1, 2},
{ 5, 2, 4},
{ 0, 0, -2},
{ 0, 0, 2},
{ 1, 3, 2}
};
static Point noscale = {0x0001,0x0001};
#else
fontab myfonts;
int MyRes[3];
Point noscale;
#endif
Str255 stringbuf;
int topmargin,nlines;
TPrint Print;
int pagenum;
SysEnvRec theWorld;
#ifdef DRIVER_MODULE
#else
}Dstorage,*DPstorage,**DHstorage;
#endif
#define SHEETDIALOG (-8193)
#define DONEITEM 1
#define STOPITEM 2